package com.libo.server.receive.impl;

import com.libo.bean.Environment;
import com.libo.server.receive.Receive;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.net.Socket;
import java.util.List;

public class ReceiveImpl implements Receive {
    @Override
    public List<Environment> receive() {
        return null;
    }


    public List<Environment> receive(Socket socket) {
        ObjectInputStream ois = null;

        try {
            ois = new ObjectInputStream(socket.getInputStream());
            List<Environment> environments = (List<Environment>) ois.readObject();
            return environments;
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }finally {
            if (ois != null){
                try {
                    ois.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
}
